package com.seanLab.repository;

/**
 * Created by ailly on 17-9-20.
 */

import com.seanLab.domain.Image;
import com.seanLab.domain.TagInfo;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import java.util.List;

/**
 * Created by ailly on 17-9-20.
 */
public interface ImageRepo extends MongoRepository<Image, String> {
    public Image findByImgID(String imgID);

    @Query("{'imgTagList':{$exists:true}, $and:[{'esFlag': 0}]}")
    public List<Image> findByImgTagListAndEsFlag(List<TagInfo> imgTagList);

    @Query("{'imgTagList':{$exists:true}, $and:[{'esFlag': 0}]}")
    public List<Image> findTop10000ByImgTagListAndEsFlag(List<TagInfo> imgTagList, Pageable pageable);

    @Query("{'topTopics':{$exists:false}}")
    public List<Image> findTop10000ByTopTopics(List<Integer> topics, Pageable pageable);

    @Query("{'esFlag':{$exists:true}}")
    public List<Image> findTop10000ByEsFlag(Pageable pageable);

    //public List<Article> findByLastName(String lastName);
    //@Query("{'', $limit:10}")
    //public List<Image> findFirst10OrderByImgID();
}
